Tuesday, April 10, 2007

javascript chess for your sidebar

A few days ago I added a chess program at the bottom of my sidebar, based on the JavaScript Chess With CPU Opponent program available here. That program had a few bugs, which I managed to straighten out, and didn't allow for the threefold repetition rule or the 50 move rule. I had toyed with making the program more capable, adding multiple levels of difficulty, but play at those levels simply became too slow. So, I just added the threefold repetition rule and 50 move rule. If you want to add the javascript chess with CPU opponent game to your blog sidebar, simply download the code from one of the links below (right click and Save As) and follow the included instructions.

There are two versions of the code available. The first version is verbose, with a bunch of documentation and proper indentation, and the second version is much more compact, for a file size of about half that of the verbose version (at the expense of readability). If you want to tinker with the program to improve the game, I strongly suggest downloading the first version. (links updated May 13 2010)

Update: Of course I can't leave well enough alone. I've been fooling around with the program, and now there are two levels of difficulty available: a fast, easy mode, and a slower, harder mode. I'm going to keep on working on this program, off and on over the next little while, and see if I can speed it up a little bit more. Right now, the hard mode is a 4-ply alpha/beta search, and if I can wrap my head around the algorithm then I'll change it to a negascout or some other fast algorithm. Once I'm satisfied with the program - which could be a week or more - I'll post the updated code.

No comments: